package com.yiyuan.app.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.guaike.core.mybatis.plugins.BaseDAO;
import com.yiyuan.app.entity.po.MRecordSeriesRechargePO;
import com.yiyuan.app.mapper.MRecordSeriesRechargeMapper;
import org.springframework.stereotype.Repository;

@Repository
public class MRecordSeriesRechargeDAO extends BaseDAO<MRecordSeriesRechargeMapper, MRecordSeriesRechargePO> {

    public MRecordSeriesRechargePO findLatestOne(Long userId) {
        LambdaQueryWrapper<MRecordSeriesRechargePO> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(MRecordSeriesRechargePO::getUserId, userId);
        queryWrapper.last("limit 0,1");
        queryWrapper.orderByDesc(MRecordSeriesRechargePO::getId);
        return getBaseMapper().selectOne(queryWrapper);
    }
}
